//
//  SubCategoryButton.m
//  Menu
//
//  Created by trimad on 11-11-24.
//  Copyright 2011 Trimad Group. All rights reserved.
//

#import "SubCategoryButton.h"
#import "Category.h"

@implementation SubCategoryButton

@synthesize category;
@synthesize point;

static int BUTTON_WIDTH = 25;
static int BUTTON_HEIGHT = 80;

+ (id)buttonWithType:(UIButtonType)buttonType point:(CGPoint) point category:(Category *)category {
	SubCategoryButton *categoryButton = [SubCategoryButton buttonWithType:buttonType];
	categoryButton.category = category;
	categoryButton.point = point;
	CGRect frame = CGRectMake(point.x, point.y, BUTTON_WIDTH, BUTTON_HEIGHT);
	categoryButton.frame = frame;
	UILabel *titleLabel = categoryButton.titleLabel;
	titleLabel.font = [UIFont boldSystemFontOfSize:18];
	[categoryButton setTitle:category.name forState:UIControlStateNormal];
	categoryButton.titleLabel.lineBreakMode = UILineBreakModeCharacterWrap;
	
	
	[categoryButton toUnselectedState];
	return categoryButton;
}

-(void)toSelectedState {
	[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	UIColor *redColor = 
		[UIColor colorWithRed:(CGFloat)182/255 green:(CGFloat)0/255 blue:(CGFloat)7/255 alpha:1.0f];

	[self setBackgroundColor:redColor];
}

-(void)toUnselectedState {
	[self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
	UIColor *lightRed = 
		[UIColor colorWithRed:(CGFloat)277/255 green:(CGFloat)158/255 blue:(CGFloat)161/255 alpha:1.0f];
	[self setBackgroundColor:lightRed];
}

@end
